import svgLoader from 'vite-svg-loader';
import createVuePlugin from '@vitejs/plugin-vue';
import createPwa from './pwa';
import createCompression from './compression';
import createJsx from './tsx';

export default function createVitePlugins(viteEnv: any, isBuild = false) {
  const vitePlugins = [createVuePlugin()];
  vitePlugins.push(createJsx());
  // eslint-disable-next-line no-unused-expressions
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  // eslint-disable-next-line no-unused-expressions
  viteEnv.VITE_BUILD_PWA === 'true' && vitePlugins.push(createPwa());
  vitePlugins.push(svgLoader());
  return vitePlugins;
}
